package com.yidian.dao;

import com.yidian.pojo.system.Resource;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author whb
 * @create 2021-06-11 13:50
 * @desciption 权限Mapper
 */
public interface ResourceMapper extends Mapper<Resource> {
    /**
     * 根据登录用户名查询权限列表
     * @param loginName
     * @return
     */
    @Select("SELECT res_key resKey FROM tb_resource WHERE id IN (" +
            "SELECT resource_id FROM tb_role_resource WHERE role_id IN (" +
            "SELECT role_id FROM tb_admin_role WHERE admin_id IN(" +
            "SELECT id FROM tb_admin WHERE login_name=#{loginName}" +
            ")" +
            ")" +
            ")")
    public List<Resource> findResourceByLoginName(@Param("loginName") String loginName);
}
